home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
SSBackground.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
3KB
|
102 lines
class SSBackground extends SSObject
{
var autoAddToScene = false;
var assetID = null;
var className = "BG";
var left = 0;
var right = 0;
var top = 0;
var bottom = 0;
var scrollMultiplier = 1;
var tileWidth = 300;
var tileHeight = 300;
var stationary = false;
var offsetX = 0;
var offsetY = 0;
function SSBackground(tileID, depth, tileWidth, tileHeight, scrollMultiplier)
{
super();
if(tileID != null)
{
this.tileID = tileID;
}
this.z = !depth ? 20 : depth;
if(tileWidth)
{
this.tileWidth = tileWidth;
}
if(tileHeight)
{
this.tileHeight = tileHeight;
}
this.scrollMultiplier = !scrollMultiplier ? 1 : scrollMultiplier;
}
function queueForDisplay()
{
}
function setPattern(g)
{
this.pattern = g;
}
function onAddDisplay()
{
if(this.stationary)
{
this.target.attachMovie(this.tileID,"bg0",0);
}
}
function setDisplay(viewport)
{
if(this.oz != (this.oz = Math.floor(this.z - viewport.z)))
{
this.target.swapDepths(this.depth = this.calculateDepth());
}
if(this.stationary)
{
this.target._x = - this.world.target._x;
this.target._y = - this.world.target._y;
return undefined;
}
var _loc11_ = Math.floor(- this.world.target._x - (x = viewport.wTan * (viewport.x * this.scrollMultiplier) / (this.z - viewport.z) + this.offsetX));
var _loc9_ = Math.floor(- this.world.target._y - (y = viewport.wTan * (viewport.y * this.scrollMultiplier) / (this.z - viewport.z) + this.offsetY));
this.target._x = _loc11_;
this.target._y = _loc9_;
this.left = x;
this.right = x + viewport.screenWidth;
this.top = y;
this.bottom = y + viewport.screenHeight;
var _loc7_ = this.leftGrid != (this.leftGrid = Math.floor(this.left / this.tileWidth));
var _loc10_ = this.rightGrid != (this.rightGrid = Math.ceil(this.right / this.tileWidth));
var _loc8_ = this.topGrid != (this.topGrid = Math.floor(this.top / this.tileHeight));
var _loc12_ = this.bottomGrid != (this.bottomGrid = Math.ceil(this.bottom / this.tileHeight));
if(!_loc7_ && !_loc10_ && !_loc8_ && !_loc12_)
{
return undefined;
}
var _loc2_ = this.tiles.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
this.tiles[_loc2_].removeMovieClip();
}
this.tiles = [];
var _loc4_ = this.rightGrid - this.leftGrid;
_loc2_ = _loc4_ * (this.bottomGrid - this.topGrid);
var _loc3_ = undefined;
var x;
var y;
var _loc5_ = 1;
while((_loc2_ = _loc2_ - 1) > -1)
{
x = this.leftGrid + _loc2_ % _loc4_;
y = y = this.topGrid + Math.floor(_loc2_ / _loc4_);
if(!(this.pattern && !(_loc5_ = this.pattern.getCell(x,y))))
{
this.tiles.push(_loc3_ = this.target.attachMovie(this.tileID,"t" + _loc2_,_loc2_));
_loc3_._x = x * this.tileWidth;
_loc3_._y = y * this.tileHeight;
_loc3_.gotoAndStop(_loc5_);
}
}
}
}